package com.lh.service.impl;

import cn.hutool.core.util.StrUtil;
import com.lh.entity.table.MaterialInfo;
import com.lh.mapper.MaterialInfoMapper;
import com.lh.service.MaterialInfoService;
import com.lh.utils.Answer;
import com.lh.utils.LogUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class MaterialInfoServiceImpl implements MaterialInfoService {

    private LogUtil LOG = new LogUtil(MaterialInfoServiceImpl.class);


    @Autowired
    private MaterialInfoMapper materialInfoMapper;

    @Override
    public Answer<Object> addMaterialInfo(MaterialInfo materialInfo) {
        try{
            String materialType = materialInfo.getMaterialType();
            Integer mainId = materialInfo.getMainId();
            if (StrUtil.isBlank(materialType)){
                return Answer.error("材料类型不能为空");
            }
            if (mainId == null){
                return Answer.error("业务id不能为空");
            }
            int insert = materialInfoMapper.insert(materialInfo);
            return Answer.ok("请求成功");
        }catch (Exception e){
            return LOG.error(Answer.build(), "请求addMaterialInfo失败！", e);
        }
    }

    @Override
    public Answer<Object> queryMaterialInfoList(MaterialInfo materialInfo) {
        try{
            return Answer.ok("请求成功");
        }catch (Exception e){
            return LOG.error(Answer.build(), "请求queryMaterialInfoList失败！", e);
        }
    }
}
